<?php
namespace App\Http\Controllers\Admin;
//引入controller控制器
use App\Http\Controllers\OwnController;
//引入请求类
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Gregwar\Captcha\CaptchaBuilder;//引入验证码类
use Illuminate\Support\Facades\Session;//引入session文件
use Cookie;//使用cookie类
use App\Models\Scenic; // 景区Model
use App\Models\Combo; //景区套餐MOdel

Class ComboController extends OwnController
{
	/**
	* 旅游套餐添加
	*/
	public function addcombo()
	{
		$scenic = new Scenic; //实例化model

		$data = $scenic->getAll(); //加载查询方法 获得数据

		return view('admin.addaccount',['data'=>$data]);

	}
	/**
	* 旅游套餐添加
	*/
	public function add_combo(Request $request)
	{
	        $file = $request->file("combo_img");//接收文件上传
	        
            //获取原文件名  
		    $time = date("Ymd",time());
            
            $file_path = $file->store($time,'uploads'); //文件名称
            // echo $file_path;exit;
            $data = Input::all(); //接收post
            
            $data['combo_img'] = $file_path;

            unset($data['_token']); //删除表单提交过来的scrf
            
            $combo = new Combo;
            
            $result = $combo->addCombo($data);
            
            if($result>0){
              
               return view("admin.index");
            }
    }

    /**
    * combo_show 套餐展示页面
    */
    public function combo_show()
    {
    	$combo = new Combo; //实例化model

    	$arr = $combo->showCombo();// 查询方法

        return view('admin.combo_show',['arr'=>$arr]);
    }
    /**
     *  combo_del 套餐删除
     */
    public function combo_del()
    {
        $arr = Input::all('id');//接收要删除的id

        $combo_id = $arr['id'];

        $combo = new Combo;

        $result = $combo->comboDel($combo_id);

        if($result>0){

            return redirect('admin/index');//跳转
        }
    }

}